package service.common;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections;

import domain.entity.SysUser;

public class PageList {
   public static Object[] toPageList(int pageIndex,int pageSize,Criteria criteria,ProjectionList project) {
	  
	   Object[] ret=new Object[2];
	   ret[1] =criteria.setProjection(  
               Projections.rowCount()).uniqueResult();
	   criteria.setProjection(project);
       criteria.setFirstResult((pageIndex - 1) * pageSize);  
       criteria.setMaxResults(pageSize);
       ret[0]=criteria.list();
       return ret;
   }
}
